home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac: Not for Sale / Another.not.for.sale (Australia).iso / fade into you / getting there / Apps / MOO-1.7.6.src / inc / functions.h < prev    next >
Text File  |  1994-11-02  |  4KB  |  111 lines

  1. /******************************************************************************
  2.   Copyright (c) 1992 Xerox Corporation.  All rights reserved.
  3.   Portions of this code were written by Stephen White, aka ghond.
  4.   Use and copying of this software and preparation of derivative works based
  5.   upon this software are permitted.  Any distribution of this software or
  6.   derivative works must comply with all applicable United States export
  7.   control laws.  This software is made available AS IS, and Xerox Corporation
  8.   makes no warranty about the software, its performance or its conformity to
  9.   any specification.  Any person obtaining a copy of this software is requested
  10.   to send their name and post office or electronic mail address to:
  11.     Pavel Curtis
  12.     Xerox PARC
  13.     3333 Coyote Hill Rd.
  14.     Palo Alto, CA 94304
  15.     Pavel@Xerox.Com
  16.  *****************************************************************************/
  17.  
  18. #ifndef Functions_h
  19. #define Functions_h 1
  20.  
  21. #include "my-stdio.h"
  22.  
  23. #include "bf_register.h" /* as a check only -- register_bf_*() functions */
  24. #include "bytecodes.h"
  25. #include "config.h"
  26. #include "structures.h"
  27.  
  28. typedef struct {
  29.   enum {BI_RAISE, BI_RETURN, BI_CALL}  why;
  30.   union {
  31.     Var ret;
  32.     enum error err;
  33.   } u;
  34.   Byte func_pc;
  35.   void *func_data;
  36. } package;
  37.  
  38. void register_bi_functions();
  39.  
  40. package make_error_pack(enum error err);
  41. package make_var_pack(Var v);
  42. package no_var_pack(void);
  43. package make_call_pack(Byte func_pc, void *func_data);
  44.  
  45. typedef package (*bf_type)(Var, Byte, void *, Objid);
  46. typedef void      (*bf_write_type)(void *vdata);
  47. typedef void   *(*bf_read_type)(FILE *f);
  48.  
  49. struct bft_entry {
  50.     const char         *name;
  51.     int                 minargs;
  52.     int                 maxargs;
  53.     var_type           *prototype;
  54.     bf_type             func;
  55.     bf_read_type    read;
  56.     bf_write_type    write;
  57. };
  58.  
  59. #define MAX_FUNC         256
  60. #define FUNC_NOT_FOUND   MAX_FUNC
  61. /* valid function numbers are 0 - 255, or a total of 256 of them.
  62.    function number 256 is reserved for func_not_found signal.
  63.    hence valid function numbers will fit in one byte but the 
  64.    func_not_found signal will not */
  65.  
  66. extern const char *name_func_by_num(unsigned);
  67. extern unsigned number_func_by_name(const char *);
  68.  
  69. extern unsigned register_function(const char *, int, int, bf_type, ...);
  70. extern unsigned register_function_with_read_write(const char *, int, int,
  71.                           bf_type, bf_read_type,
  72.                           bf_write_type, ...);
  73. extern void free_bf_table(void);
  74.  
  75. extern package     call_bi_func(unsigned, Var, Byte, Objid, void *); 
  76. /* will free or use Var arglist */
  77.  
  78. extern void     write_bi_func_data(void *vdata, Byte f_id);
  79. extern int    read_bi_func_data(FILE *f, Byte f_id, void **bi_func_state);
  80.  
  81. #endif
  82.  
  83. /* $Log: functions.h,v $
  84.  * Revision 1.8  1992/10/23  23:03:47  pavel
  85.  * Added copyright notice.
  86.  *
  87.  * Revision 1.7  1992/10/21  03:02:35  pavel
  88.  * Converted to use new automatic configuration system.
  89.  *
  90.  * Revision 1.6  1992/10/17  20:31:21  pavel
  91.  * Changed return-type of read_bi_func_data() from char to int, for systems
  92.  * that use unsigned chars.
  93.  *
  94.  * Revision 1.5  1992/08/14  00:00:56  pavel
  95.  * Converted to a typedef of `var_type' = `enum var_type'.
  96.  *
  97.  * Revision 1.4  1992/08/13  21:25:52  pjames
  98.  * Added register_bi_functions() which registers all bi_functions.
  99.  *
  100.  * Revision 1.3  1992/08/12  01:49:19  pjames
  101.  * Var_types in bft_entry is now a pointer instead of a preallocated array.
  102.  *
  103.  * Revision 1.2  1992/08/10  17:38:21  pjames
  104.  * Added func_pc and func_data to package struct.  Built in functions now
  105.  * receive an Objid (progr) instead of a Parse_Info.  Changed
  106.  * registration method to use var_args.
  107.  *
  108.  * Revision 1.1  1992/07/20  23:23:12  pavel
  109.  * Initial RCS-controlled version.
  110.  */
  111.